package org.example.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 处理@Autowired，@Value ，@Inject注解.
 * 入口：AutowiredAnnotationBeanPostProcessor
 *
 * 1.寻找注入点并缓存：
 * MergedBeanDefinitionPostProcessor#
 * postProcessMergedBeanDefinition(RootBeanDefinition bd, Class<?> beanType, String beanName)
 * 2.属性注入:
 * InstantiationAwareBeanPostProcessor
 * #postProcessProperties(PropertyValues pvs, Object bean, String beanName)
 */
@Component
public class UserServiceImpl implements UserService {

	@Value("${config.test}")
	private String config;

	@Autowired
//	@Lazy
	private OrderService orderService;

	public void test(){
		System.out.println(orderService);
	}

	public void config(){
		System.out.println(config);
	}


	@PostConstruct
	@Override
	public void init() {
		System.out.println("UserService#PostConstruct say init");
	}


}
